﻿<?php

if(!defined('IN_PHPSCUP'))exit('hacking'); 
class HtmlApp extends BaseApp
{

	var $htmldata = array('1'=>array('name'=>'新闻管理','app'=>'new','act'=>'show'),'2'=>array('name'=>'产品管理','app'=>'prot','act'=>'show'));
	
    function index()
    {

		$this->assign('htmldata', $this->htmldata);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));	
		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
		
        $this->display('html.view.html');

    }
	

    function dohtml()
    {
	    if(!isset($_GET['id']))
		{
		$_GET['id'] = '';
		}
	   	$v = $_GET['id'];
        if($v == 'index')
		{
		 $content = @file_get_contents(SITE_URL.'/index.php?langid='.trim($GLOBALS['Lang']->_lang_tp));		
		 $cachefilename = ROOT_PATH .'/index.html';	 
		 file_put_contents($cachefilename,$content);
		 $notice = &get_message(array('msg'=>"主页静态成功!",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();

		}
        

        $temp = $_POST['data'];
		$v = $temp['moduleid'];
        if($v == '')
		{
		 $notice = &get_message(array('msg'=>"没有选择模块!",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();
		}  
        if($temp['startid'] >= $temp['endid'])
		{
		 $notice = &get_message(array('msg'=>"开始id号不能大于等于结束id号",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();
		} 		

/*
        if($temp['startid'] == '')
		{
		 $notice = &get_message(array('msg'=>"开始id号没有设置",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();
		}      
        if($temp['endid'] == '')
		{
		 $notice = &get_message(array('msg'=>"结束id号没有设置",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();
		}    
*/
		$TB_html = &$this->_model('html'); 
		$data = $TB_html->allhtml($v,$temp['startid'],$temp['endid'],$temp['num']);
		
		$view = &get_view();
        foreach($data as $key => $value)
		{
	    $view->html($value['id'],SITE_URL ."/?app=".$this->htmldata[$v]['app']."&act=".$this->htmldata[$v]['act']."&langid=".$value['lang_type']."&id=".$value['id'],$this->htmldata[$v]['app']);	
		
		}

		 $notice = &get_message(array('msg'=>$this->htmldata[$v]['name'].".....Success!",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();

    }


    function doallhtml()
    {
	   	$v = $_GET['v'];

		$TB_html = &$this->_model('html'); 
		$data = $TB_html->alltohtml($v);
		
		$view = &get_view();
        foreach($data as $key => $value)
		{
	    $view->html($value['id'],SITE_URL ."/?app=".$this->htmldata[$v]['app']."&act=".$this->htmldata[$v]['act']."&langid=".$value['lang_type']."&id=".$value['id'],$this->htmldata[$v]['app']);	
		
		}

		 $notice = &get_message(array('msg'=>$this->htmldata[$v]['name'].".....Success!",'url'=>'?app=html&act=index','title'=>'Notice','skip_time'=>1000));
		 $notice ->display();

    }

}





?>